#!/bin/sh

set -e

remove_cruft() {
  CRUFT="/etc/logrotate.d/acpid* /var/log/acpid* /etc/acpi/powerbtn.sh* /etc/acpi/events/powerbtn*"
  BACKUP="/var/backups/acpid-cruft.tar.gz"
  tar cfz $BACKUP $CRUFT || true
  chmod 600 $BACKUP
  rm -f $CRUFT
}


case "$1" in
  configure|reconfigure)
    if test -n "$2" && dpkg --compare-versions "$2" lt 1.0.6-2; then
      remove_cruft
    fi
    if [ -x /etc/init.d/hal ]; then
      invoke-rc.d hal stop
    fi
    ;;

  *)
    echo "postinst called with unknown argument \`$1'" 1>&2
    exit 1
    ;;
esac

#DEBHELPER#

case "$1" in
  configure|reconfigure)
    if [ -x /etc/init.d/hal ]; then
      invoke-rc.d hal start
    fi
    ;;
esac

